import { createRouter, createWebHistory } from 'vue-router';
import Layout from '@/layout/index.vue';

// 静态路由
const staticRoutes = [
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [
      {
        path: '/dashboard',
        name: 'dashboard',
        component: () => import('@/views/dashboard/index.vue'),
        meta: { title: '首页', icon: 'ant-design:home-outlined' },
      },
    ],
  },
];

//
// 动态路由
const dynamicRoutes = [
  {
    path: '/documentation',
    component: Layout,
    redirect: '/documentation/index',
    children: [
      {
        path: '/index',
        name: 'documentation',
        component: () => import('@/views/dashboard/index.vue'),
        meta: { title: '文档', icon: 'ant-design:file-word-outlined' },
      },
    ],
  },
  {
    path: '/systems',
    component: Layout,
    redirect: '/systems/menu',
    meta: { title: '系统', icon: 'ant-design:setting-twotone' },
    children: [
      {
        path: '/menu',
        name: '菜单',
        component: () => import('@/views/dashboard/index.vue'),
        meta: { title: '菜单', icon: 'ant-design:apartment-outlined' },
      },
      {
        path: '/user',
        name: '用户',
        component: () => import('@/views/dashboard/index.vue'),
        meta: { title: '用户', icon: 'ant-design:user-outlined' },
      },
      {
        path: '/role',
        name: '角色',
        component: () => import('@/views/dashboard/index.vue'),
        meta: { title: '角色', icon: 'ant-design:robot-outlined' },
      },
    ],
  },
];

export const routes = [...staticRoutes, ...dynamicRoutes];
const router = createRouter({
  history: createWebHistory(),
  routes,
});
export default router;
